package com.swpu.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.swpu.project.common.BaseResponse;
import com.swpu.project.mapper.RoleMapper;
import com.swpu.project.model.entity.Role;
import com.swpu.project.model.page.PageQuery;
import com.swpu.project.model.page.RoleDto;
import com.swpu.project.service.IRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author ma
 * @since 2024-08-28
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
 @Resource
 RoleMapper roleMapper;

    @Override
    public BaseResponse queryPage(PageQuery pageQuery) {
        Integer pageNum = pageQuery.getPageNum();
        Integer pageSize = pageQuery.getPageSize();
       int start=(pageNum-1)*pageSize;
       int end=pageSize;
        List<RoleDto> roleDtos = roleMapper.selectPageRoleWithMenus(start, end, pageQuery.getSortBy(), pageQuery.getQueryBy());

    return BaseResponse.ok(roleDtos);
    }
}
